package o;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import com.huawei.appgallery.foundation.ui.framework.uikit.annotation.Inject;
import java.lang.reflect.Field;

public class cjm {
    protected cjo ˋ;
    protected cjn ˏ;
    protected Intent ॱ;

    public cjm(String str, cjo o_cjo) {
        Class ˋ = cjl.ˋ(str);
        if (ˋ != null) {
            this.ˏ = new cjc(ˋ);
        } else {
            ˋ = cjl.ॱ(str);
            if (ˋ != null) {
                this.ˏ = new cjh(ˋ);
            }
        }
        this.ˋ = o_cjo;
        if (this.ˏ == null) {
            throw new IllegalArgumentException(str + " is not registered!");
        }
    }

    public cjm(cjn o_cjn, cjo o_cjo) {
        this.ˏ = o_cjn;
        this.ˋ = o_cjo;
    }

    public Intent ॱ(Context context) {
        Intent ˋ = ˋ();
        ˋ.setClass(context, this.ˏ.ˋ());
        return ˋ;
    }

    public Intent ॱ() {
        return ˋ();
    }

    private Intent ˋ() {
        if (this.ॱ == null) {
            this.ॱ = new Intent();
        }
        this.ॱ.putExtra("_protocol", ˏ());
        return this.ॱ;
    }

    protected Bundle ˏ() {
        if (this.ˋ == null) {
            return null;
        }
        ˊ();
        return new cjt().ˏ(this.ˋ, new Bundle());
    }

    protected void ˊ() {
        if (this.ˋ != null) {
            for (Class cls = this.ˋ.getClass(); cls != null; cls = cls.getSuperclass()) {
                for (Field field : cls.getDeclaredFields()) {
                    if (field.isAnnotationPresent(Inject.class)) {
                        try {
                            ॱ(this.ˋ, field);
                        } catch (IllegalAccessException e) {
                            ckx.ˎ.ˊ("Offer", "inject error IllegalAccessException!");
                        }
                    }
                }
            }
        }
    }

    private void ॱ(cjo o_cjo, Field field) throws IllegalAccessException {
        boolean isAccessible = field.isAccessible();
        field.setAccessible(true);
        if (field.get(o_cjo) == null) {
            String value = ((Inject) field.getAnnotation(Inject.class)).value();
            if (field.getType().isAssignableFrom(cjc.class)) {
                field.set(o_cjo, cjc.ˎ(cjl.ˋ(value)));
            } else {
                field.set(o_cjo, cjh.ॱ(cjl.ॱ(value)));
            }
        }
        field.setAccessible(isAccessible);
    }
}
